<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>数据统计</title>

		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/app.css" />
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link href="css/new_file.css" rel="stylesheet" type="text/css">

		<script src="js/mui.min.js"></script>
		<script src="js/mui.picker.min.js"></script>

		<script src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>

	</head>

	<body>

		<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="Returnfunction()">
			<div class="search-tjxq">
				<input id="searchData" class="tjxq-search-btn" type="text" value="请输入奶牛耳号" onfocus="if(value==defaultValue){value='';this.style.color='#ffffff'}" onblur="if(!value){value=defaultValue;this.style.color='#ffffff'}" style="background:none;color: rgb(255,255,255);">
				<img class="sousuo-tjxq" src="images/serach-w.png" onclick="findsearchCow()">
			</div>
		</div>
		<div class="nzlbzz">
			<div class="nzlb_meau" onclick="clicksinglen()">
				<div class="nzlb_meau_nr nzlb_meau_nr_hover" ce_result='' >
					<div class="nzlb_meau_nr_wx">15</div>
					<div>全部</div>
				</div>
				<div class="nzlb_meau_nr" ce_result='0'>
					<div class="nzlb_meau_nr_wx">15</div>
					<div>未发情</div>
				</div>
				<div class="nzlb_meau_nr" ce_result='1'>
					<div class="nzlb_meau_nr_wx">15</div>
					<div>发情未判定</div>
				</div>
				<div class="nzlb_meau_nr" ce_result='2'>
					<div class="nzlb_meau_nr_wx">15</div>
					<div>判断发情</div>
				</div>
				<div class="nzlb_meau_nr" ce_result='3'>
					<div class="nzlb_meau_nr_wx">15</div>
					<div>判断未发情</div>
				</div>
				<div class="nzlb_meau_nr" ce_result='4'>
					<div class="nzlb_meau_nr_wx">15</div>
					<div>人工判断</div>
				</div>
				

			</div>
			<div class="nzlb_rili" id="nzlb_rili" data-options="{}"><img src="images/rili_tu.png"></div>
		</div>
		<p id="timenow" align="center">2019-7-1</p>
		<div class="liebiao-div" id="tableCellID" style="margin-top: 0px">
		</div>
		<div class="nzlb_tc" id="lu_nzlb_tc" style="display: none;">
			<div class="nzlb_tc_nr">
				<div class="nzlb_tc_nr_bt" id="ovibitContent">12643 判定揭发情况</div>
				<div class="nzlb_tc_nr_an">
					<a class="nzlb_tc_nr_an_a" id="lu_faqing" cow_id="" onclick="fqingDetermine()">发情</a>
					<a class="nzlb_tc_nr_an_a" onclick="hideweifaq()">未发情</a>
				</div>
				<div class="nzlb_tc_nr_qx" onclick="hideweifaq()">取消</div>
			</div>
		</div>
		<!-- 疑似发情判断弹框-->
		<div class="nzlb_tc" style="display: none;" id="lu_pan">
			<div class="nzlb_tc_nr" >
				<div class="nzlb_tc_nr_bt" id="lu_pan_ob">12643 判定揭发情况</div>
				<div class="nzlb_tc_nr_an">
					<a class="nzlb_tc_nr_an_a" cow_id="" id="lu_pan_y" onclick="OestrusInterface(2)">判定发情</a>
					<a class="nzlb_tc_nr_an_a" cow_id="" id="lu_pan_n" onclick="OestrusInterface(3)">判定未发情</a>
				</div>
				<div class="nzlb_tc_nr_qx" onclick="hideysfaq()">取消</div>
			</div>
		</div>
		<script>
			var pageNumber = 2;
			var times;
			var butStr = 0;
			var datastatisData = JSON.parse(localStorage.getItem('datastatisData'));
			var tableCellID = document.getElementById('tableCellID');
			//			wholeArr = bb.data;
			if(datastatisData.length != 20) {
				butStr = 1;
			}
			huitu();

			for(var i = 0; i < datastatisData.length; i++) {
				if(datastatisData[i].countDown != undefined) {
					resetTime('s' + datastatisData[i].cow_id, datastatisData[i].countDown);
				}
			}

			function FindACow() {
				mui.alert("设备未上线，无法预约找牛");
			}

	

		function findCowEvent(){
		
			var cows;
			var time;
			var cowsID;
			(function($) {
				$.init();
				//					var resultss = $('#result')[0];
				var btns = $('.btn');
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						var optionsJson = this.getAttribute('data-options') || '{}';
						var options = JSON.parse(optionsJson);
						console.log(options);
						var id = this.getAttribute('id');
						_self.picker = new $.DtPicker(options);
						_self.picker.show(function(rs) {
							cowsID = id;
							cows = id.substr(1);
							time = rs.text;
							findCowBut();
							_self.picker.dispose();
							_self.picker = null;
						});
					}, false);
				});
			})(mui);

			function findCowBut(){ 
				var str = $("#s" + cows).html();
				if(str == "找牛") {
					var keys = JSON.parse(localStorage.getItem('key'));
					var arr = new Array();
					arr.push(cows);
					var map = {};
					map.key = keys;
					map.cows = arr;
					map.time = time;
					map.phoneType = "android";
					map.language = "zh";
					var jsonStr = JSON.stringify(map);

					showDialog();
					var ajaxTimeoutTest = $.ajax({
						type: "POST",
						url: url_prefix + "findCow",
						dataType: 'JSON',
						timeout: 10000,
						data: {
							'request': encryptByDES(jsonStr)
						},
						success: function(data) {
							dismissDialog();
							var str1 = decryptByDESModeEBC(data["result"]); //解密
							var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
							var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
							var datas = JSON.stringify(str2); //转JSON字符串
							var aa = datas.replace(/\\n/g, " "); //去掉换行
							var objs = eval('(' + aa + ')');
							var bb = eval('(' + objs + ')');

							if(bb.head.status == 1) {

								times = parseInt(bb.data.returnList[0].Countdown);
								resetTime(cowsID, times);
								//								window.location = "发情揭发.html";
							} else {

								mui.alert(bb.head.info);
							}
						},
						complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
							dismissDialog();
							if(status == 'timeout') { //超时,status还有success,error等值的情况
								ajaxTimeoutTest.abort();　　　　　
								mui.alert("网络请求超时...");　　　　
							}　　
						}
					});
				} else {
					mui.alert("已在找牛中。。。");
				}
			}
 		}
			var remark;
			var time;

			function OestrusDetermination(id) {
				if(datastatisData[id].result == "疑似发情") {
					document.getElementById("lu_pan_ob").innerHTML=datastatisData[id].overbit+"判定揭发情况";
					document.getElementById("lu_pan_y").setAttribute("cow_id",datastatisData[id].cow_id);
					showysfaq();					
				}else if(datastatisData[id].result == "未发情"){
					document.getElementById("ovibitContent").innerHTML=datastatisData[id].overbit+"判定揭发情况";
					document.getElementById("lu_faqing").setAttribute("cow_id",datastatisData[id].cow_id);
					showweifaq();					
				}else if(datastatisData[id].result == "确认发情"){
					mui.toast("该奶牛以人工确认发情");
				}else if(datastatisData[id].result == "确认未发情"){
					mui.toast("该奶牛以人工确认未发情");
				}else if(datastatisData[id].result == "人工揭发发情"){
					mui.toast("该奶牛以人工揭发发情");
				}
				
			}

			function OestrusInterface(result) {
				var cow_id=document.getElementById("lu_pan_y").attributes["cow_id"].nodeValue;
				var keys = JSON.parse(localStorage.getItem('key'));
				var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'));
				var map = {};
				map.key = keys;
				map.cowID = cow_id;
				map.result = result;//判定未发情
//				map.remark = remark.value;
				map.date = JSON.parse(localStorage.getItem('timenow'));
				map.phoneType = "android";
				map.language = "zh";
				console.log(map);
				var jsonStr = JSON.stringify(map);
				showDialog();
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "estrusDetermination",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						dismissDialog();
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							hideysfaq();
							findsearchCow();													
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						dismissDialog();
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();　　　　　
							mui.alert("网络请求超时...");　　　　
						}　　
					}
				});
			}

			function OestrusDetails(id) {
				var keys = JSON.parse(localStorage.getItem('key'));
				var map = {};
				map.key = keys;
				map.cowID = datastatisData[Number(id)]["cow_id"];
				map.date=JSON.parse(localStorage.getItem('timenow'));
				console.log(map["cowID"]);
				map.phoneType = "android";
				map.language = "zh";
				var jsonStr = JSON.stringify(map);
				showDialog();
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "oestrus",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					async:false,
					success: function(data) {
						dismissDialog();
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							localStorage.setItem('OestrusDetailsData', JSON.stringify(bb.data));
							localStorage.setItem('lu_route', JSON.stringify("数据统计"));
							localStorage.setItem('Cow_Id', JSON.stringify(map.cowID));
							localStorage.setItem('paramsNameDate', JSON.stringify(map.date));
							window.location = "发情详情.html";
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						dismissDialog();
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();　　　　　
							mui.alert("网络请求超时...");　　　　
						}　　
					}
				});
			}

			function fanhuizhuan() {
				localStorage.setItem('ToChangeIntoNumber', JSON.stringify(0));
				localStorage.setItem('TurnOutNumber', JSON.stringify(0));
				emotionalSuccessRate();
			}

			function resetTime(id, times) {  
				var timer = null;  
				var t = times; 

				var h = 0; 
				var m = 0;  
				var s = 0; 
				h = parseInt(t / 3600)
				m = parseInt(t / 60 % 60);  
				m < 10 && (m = '0' + m);  
				s = Math.floor(t % 60);  
				function countDown() {   
					s--;   
					s < 10 && (s = '0' + s);  
					if(s.length >= 3) {  
						if(Number(m) == 0) {
							s = 59; 
							m = 59;   
							h = (Number(h) - 1);
						} else {
							s = 59;    
							m = (Number(m) - 1);
						}  
					}
					if(m < 10) {
						m = "0" + Number(m);
					}
					//					if(h.length >= 3) { 
					//						h = '0';    
					//						m = '00';    
					//						s = '00';    
					//						clearInterval(timer);   
					//					}   


					$("#" + id).html(h + ":" + m + ":" + s); 
					if(s == '00' && m == '00' && h == '0') {
						clearInterval(timer);
						$("#" + id).html("已亮灯");
						return;
					}
				}  
				timer = setInterval(countDown, 1000);
			}

			//获取滚动条当前的位置 
			function getScrollTop() {
				var scrollTop = 0;
				if(document.documentElement && document.documentElement.scrollTop) {
					scrollTop = document.documentElement.scrollTop;
				} else if(document.body) {
					scrollTop = document.body.scrollTop;
				}
				return scrollTop;
			}

			//获取当前可视范围的高度 
			function getClientHeight() {
				var clientHeight = 0;
				if(document.body.clientHeight && document.documentElement.clientHeight) {
					clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
				} else {
					clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
				}
				return clientHeight;
			}

			//获取文档完整的高度 
			function getScrollHeight() {
				return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
			}
			window.onscroll = function() {
//				console.log(getScrollTop() +"+"+ getClientHeight()+" >= "+getScrollHeight());
				console.log("butStr="+butStr+"  pageNumber="+pageNumber);
				if(getScrollTop() + getClientHeight() >= getScrollHeight()-6) { //ajax从这里开始
					if(butStr == 1) {
						mui.toast("没有更多数据了")
					} else {
						var type = JSON.parse(localStorage.getItem('DetailsType'));
						var keys = JSON.parse(localStorage.getItem('key'));
						var map = {};
						map.timenow=JSON.parse(localStorage.getItem("timenow"));
						var result=JSON.parse(localStorage.getItem("result"));
						if(result==null){
							result="";
						}
						map.result=result;
						map.key = keys;
						map.page = pageNumber;
						map.size = 20;
						if(type == 1 || type == 2 || type == 3) {
							var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'))
							map.startDate = paramsName;
							map.endDate = paramsName;
						}
						map.type = type;
						map.phoneType = "android";
						map.language = "zh";
						var jsonStr = JSON.stringify(map);
						console.log(jsonStr);
						showDialog();
						var ajaxTimeoutTest = $.ajax({
							type: "POST",
							url: url_prefix + "datastatis",
							dataType: 'JSON',
							timeout: 10000,
							data: {
								'request': encryptByDES(jsonStr)
							},
							success: function(data) {
								dismissDialog();
								var str1 = decryptByDESModeEBC(data["result"]); //解密
								var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
								var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
								var datas = JSON.stringify(str2); //转JSON字符串
								var aa = datas.replace(/\\n/g, " "); //去掉换行
								var objs = eval('(' + aa + ')');
								var bb = eval('(' + objs + ')');
								if(bb.head.status == 1) {
									if(bb.data.length != 20) {
										butStr = 1;
										console.log("长度"+bb.data.length);
									}
									if(bb.data.length == 0) {
										mui.toast("没有更多数据了");
									}
									for(var i = 0; i < bb.data.length; i++) {
										datastatisData.push(bb.data[i]);
									}
									pageNumber ++;
									huitu();
								} else {
									mui.alert(bb.head.info);
								}
							},
							complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
								dismissDialog();
								if(status == 'timeout') { //超时,status还有success,error等值的情况
									ajaxTimeoutTest.abort();　　　　　
									mui.alert("网络请求超时...");　　　　
								}　　
							}
						});
					}
				}
			}

//			function huitu() {
				//绘制单个div
				function setDiv(item, i) {

					if(item.result == 0) {
						item.result = "未发情";
					} else if(item.result == 1) {
						item.result = "疑似发情";
					} else if(item.result == 2) {
						item.result = "确认发情";
					} else if(item.result == 3) {
						item.result = "确认未发情";
					} else if(item.result == 4) {
						item.result = "人工揭发发情";
					}

					if(item.AllowLightTime == null) {
						var exposeTimeStr='';
						if(item.exposeTime!=''){
							exposeTimeStr='<div class="liebiao-aa"><p class="liebiao-l">揭发时间</p><p class="liebiao-r">' +
							item.exposeTime+
							'</p><div class="clear"></div></div>';
						}
						var div = '<div id="0' + i + '" onclick="OestrusDetails(this.id)"><img class="liebiao-que-l" src="images/banyuan@3x.png" /><img class="liebiao-que-r" src="images/banyuan-right@3x.png" /><div class="xulieh-div"><p class="xulie-p">' +
							item.device_serial +
							'</p><p class="biaoqian-b" style="font-size: 14px;">' +
							item.conceive +
							'</p></div><div><div class="liebiao-aa"><p class="liebiao-l">奶牛耳号</p><p class="liebiao-r">' +
							item.overbit +
							'</p><div class="clear"></div></div>'+exposeTimeStr+'<div class="liebiao-aa"><p class="liebiao-l">泌乳天数</p><p class="liebiao-r">' +
							item.lactationDate+
							'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">类型</p><p class="liebiao-r">' +
							item.cowType +
							'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">牛舍</p><p class="liebiao-r">' +
							item.cowHouseName +
							'</p><div class="clear"></div></div></div></div><div class="fqpd"><div class="fqpd-ss"><p id="' + i +
							'" onclick="OestrusDetermination(this.id)">' +
							item.result +
							'</p></div><div class="fqpd-ss"><div class="fengx"></div><p id="s' + item.cow_id +
							'" style="padding: 0;border: none;font-size: 14px;color: #2d82ff;margin-bottom: 0px;line-height: 28px;">找牛</p></div><div class="clear"></div></div><div style="height:12px;	background: #F0F0F0;"></div>'
					} else {
						var exposeTimeStr='';
						if(item.exposeTime!=''){
							exposeTimeStr='<div class="liebiao-aa"><p class="liebiao-l">揭发时间</p><p class="liebiao-r">' +
							item.exposeTime+
							'</p><div class="clear"></div></div>';
						}
						var div = '<div id="0' + i + '" onclick="OestrusDetails(this.id)"><img class="liebiao-que-l" src="images/banyuan@3x.png" /><img class="liebiao-que-r" src="images/banyuan-right@3x.png" /><div class="xulieh-div"><p class="xulie-p">' +
							item.device_serial +
							'</p><p class="biaoqian-b" style="font-size: 14px;">' +
							item.conceive +
							'</p></div><div><div class="liebiao-aa"><p class="liebiao-l">奶牛耳号</p><p class="liebiao-r">' +
							item.overbit +
							'</p><div class="clear"></div></div> '+exposeTimeStr+'<div class="liebiao-aa"><p class="liebiao-l">泌乳天数</p><p class="liebiao-r">' +
							item.lactationDate+
							'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">类型</p><p class="liebiao-r">' +
							item.cowType +
							'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">牛舍</p><p class="liebiao-r">' +
							item.cowHouseName +
							'</p><div class="clear"></div></div></div></div><div class="fqpd"><div class="fqpd-ss"><p id="' + i +
							'" onclick="OestrusDetermination(this.id)">' +
							item.result +
							'</p></div><div class="fqpd-ss"><div class="fengx"></div><p id="s' + item.cow_id +
							'"  data-options=\'{"beginYear":' +
							parseInt(item.AllowLightTime.substr(0, 4)) +
							',"beginMonth":' +
							parseInt(item.AllowLightTime.substr(5, 2)) +
							',"beginDay":' +
							parseInt(item.AllowLightTime.substr(8, 2)) +
							',"beginHours":' +
							parseInt(item.AllowLightTime.substr(11, 2)) +
							'}\' class="btn mui-btn mui-btn-block" style="padding: 0;border: none;font-size: 14px;color: #2d82ff;margin-bottom: 0px;line-height: 28px;">找牛</p></div><div class="clear"></div></div><div style="height:12px;	background: #F0F0F0;"></div>'
					}
					return div
				}

				function getnoApplicationData() {
					//显示发情情况
					showOestrus();
					//初始化时间
					shijiang();
					var html = ''
					for(var i = 0; i < datastatisData.length; i++) {
						//					datastatisData[i]["AllowLightTime"] = "2018-09-25 23:15:09";
						html += setDiv(datastatisData[i], i)
					}
					tableCellID.innerHTML = html
					//绑定找牛事件
					findCowEvent();
				}
			function huitu() {	
				window.onload = getnoApplicationData()
			}
             //初始化时间
		     function shijiang(){
		     	var timenow=JSON.parse(localStorage.getItem('timenow'));	
				    document.getElementById("timenow").innerText=timenow;	     			
		     }
			//获取时间mui插件
			(function($) {
				$.init();
					$('#nzlb_rili')[0].addEventListener('tap', function() {
						var _self = this;
//						var optionsJson = this.getAttribute('data-options') || '{}';
//						var options = JSON.parse(optionsJson);
						var options={type:"date",beginYear:2016};
						_self.picker = new $.DtPicker(options);
						_self.picker.show(function(rs) {
							localStorage.setItem('timenow', JSON.stringify(rs.text));
							document.getElementById("timenow").innerText=rs.text;
							findsearchCow();
							_self.picker.dispose();
							_self.picker = null;
						});
					}, false);
			})(mui);
		function searchCow(map){			
			var type = JSON.parse(localStorage.getItem('DetailsType'));
			var keys = JSON.parse(localStorage.getItem('key'));
			if(map==null){
				var map = {};
			}
			map.timenow=JSON.parse(localStorage.getItem("timenow"));
			var result=JSON.parse(localStorage.getItem("result"));
			if(result==null){
				result="";
			}
			map.result=result;
			map.key = keys;
			map.page = 1;
			map.size = 20;
			if(type == 1 || type == 2 || type == 3) {
				var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'))
				map.startDate = paramsName;
				map.endDate = paramsName;
			}
			map.type = type;
			map.phoneType = "android";
			map.language = "zh";
			var jsonStr = JSON.stringify(map);

			showDialog();
			var ajaxTimeoutTest = $.ajax({
				type: "POST",
				url: url_prefix + "datastatis",
				dataType: 'JSON',
				timeout: 10000,
				data: {
					'request': encryptByDES(jsonStr)
				},
				success: function(data) {
					dismissDialog();
					var str1 = decryptByDESModeEBC(data["result"]); //解密
					var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
					var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
					var datas = JSON.stringify(str2); //转JSON字符串
					var aa = datas.replace(/\\n/g, " "); //去掉换行
					var objs = eval('(' + aa + ')');
					var bb = eval('(' + objs + ')');
					if(bb.head.status == 1) {
						if(bb.data.length != 20) {
							butStr = 1;
						}
						if(bb.data.length == 0) {
							mui.toast("没有更多数据了");
						}
						localStorage.setItem('datastatisData', JSON.stringify(bb.data));
						datastatisData = JSON.parse(localStorage.getItem('datastatisData'));
						huitu();
					} else {
						mui.alert(bb.head.info);
					}
					localStorage.setItem('locklu', JSON.stringify("locklu"));
				},
				complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
					dismissDialog();
					if(status == 'timeout') { //超时,status还有success,error等值的情况
						ajaxTimeoutTest.abort();　　　　　
						mui.alert("网络请求超时...");　　　　
					}　　
				}
			}); 
		}
		//显示发情情况
		function showOestrus(){
			var timenow=JSON.parse(localStorage.getItem('timenow'));
			var type = JSON.parse(localStorage.getItem('DetailsType'));
			var keys = JSON.parse(localStorage.getItem('key'));
			var map = {};
			map.timenow=timenow;
			map.key = keys;
			map.phoneType = "android";
			map.language = "zh";
			var jsonStr = JSON.stringify(map);

			showDialog();
			var ajaxTimeoutTest = $.ajax({
				type: "POST",
				url: url_prefix + "showOestrus",
				dataType: 'JSON',
				timeout: 10000,
				data: {
					'request': encryptByDES(jsonStr)
				},
				success: function(data) {
					dismissDialog();
					var str1 = decryptByDESModeEBC(data["result"]); //解密
					var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
					var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
					var datas = JSON.stringify(str2); //转JSON字符串
					var aa = datas.replace(/\\n/g, " "); //去掉换行
					var objs = eval('(' + aa + ')');
					var bb = eval('(' + objs + ')');
					if(bb.head.status == 1) {
						localStorage.setItem('showOestrusData', JSON.stringify(bb.data));
						loadingOestrusPage();
					} else {
						mui.alert(bb.head.info);
					}
				},
				complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
					dismissDialog();
					if(status == 'timeout') { //超时,status还有success,error等值的情况
						ajaxTimeoutTest.abort();　　　　　
						mui.alert("网络请求超时...");　　　　
					}　　
				}
			}); 
		}
		//加载发情情况数量
		function loadingOestrusPage(){
			var meaus = $('.nzlb_meau_nr_wx');
			var showOestrusData=JSON.parse(localStorage.getItem('showOestrusData'));
//			var target=0;
//			for(var i=0;i<showOestrusData.length;i++){
//				target=target+showOestrusData[i].number;
//			}
			meaus.each(function(i, btn) {
//				if(i==0){
//					this.innerHTML=target;
//				}else{
					this.innerHTML=showOestrusData[i].number;
//				}
			});
		}
		//点击当个发情情况
		function clicksinglen(){
			var btns = $('.nzlb_meau_nr');
			btns.each(function(i, btn) {
				btn.addEventListener('tap', function() {
					var locklu=JSON.parse(localStorage.getItem('locklu'));//锁
					if(locklu=="locklu"){
						removeAllClass();
						addClass(this, "nzlb_meau_nr_hover");
						butStr = 0;
						pageNumber = 2;
						localStorage.setItem('locklu', JSON.stringify("lockshuai"));
						var result=this.getAttribute('ce_result');
						localStorage.setItem('result', JSON.stringify(result));
						var map={};
						map.result=result;
						searchCow(map);	
//						localStorage.setItem('locklu', JSON.stringify("locklu"));
					}else{
//						mui.alert("操作过快");　
					}
				}, false);
			});
		}
		
		function removeAllClass(){
			var btns = $('.nzlb_meau_nr');
				btns.each(function(i, btn) {
					removeClass(this, "nzlb_meau_nr_hover");
				}, false);
		}
		function addClass(element, className) {
		  if(!new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className)) element.className += ' ' + className;
		}
		function removeClass(element, className) {
		  element.className = element.className.replace(new RegExp("(^|\\s)" + className + "(?=(\\s|$))", "g"), '');
		}
		function findsearchCow(){
			var locklu=JSON.parse(localStorage.getItem('locklu'));//锁
			if(locklu=="locklu"){
				localStorage.setItem('locklu', JSON.stringify("lockshuai"));
				butStr = 0;
				pageNumber = 2;
				var overbit=document.getElementById("searchData").value;			
				if(overbit=="请输入奶牛耳号"){
					overbit="";
				}
				var map={};
				map.overbit=overbit;
				searchCow(map);	
			}else{
			}
		}
		function showweifaq(){
			var weifaq=document.getElementById("lu_nzlb_tc");
			weifaq.style.display="block";
		}
		function hideweifaq(){
			var weifaq=document.getElementById("lu_nzlb_tc");
			weifaq.style.display="none";
		}
		function showysfaq(){
			var weifaq=document.getElementById("lu_pan");
			weifaq.style.display="block";
		}
		function hideysfaq(){
			var weifaq=document.getElementById("lu_pan");
			weifaq.style.display="none";
		}
		function fqingDetermine(){
		var cow_id=document.getElementById("lu_faqing").attributes["cow_id"].nodeValue;
			var keys = JSON.parse(localStorage.getItem('key'));
			if(map==null){
				var map = {};
			}
			map.cow_id=cow_id;
			map.timenow=JSON.parse(localStorage.getItem("timenow"));
			map.key = keys;
			map.phoneType = "android";
			map.language = "zh";
			var jsonStr = JSON.stringify(map);
			showDialog();
			var ajaxTimeoutTest = $.ajax({
				type: "POST",
				url: url_prefix + "fqingDetermine",
				dataType: 'JSON',
				timeout: 10000,
				data: {
					'request': encryptByDES(jsonStr)
				},
				success: function(data) {
					dismissDialog();
					var str1 = decryptByDESModeEBC(data["result"]); //解密
					var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
					var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
					var datas = JSON.stringify(str2); //转JSON字符串
					var aa = datas.replace(/\\n/g, " "); //去掉换行
					var objs = eval('(' + aa + ')');
					var bb = eval('(' + objs + ')');
					if(bb.head.status == 1) {
						hideweifaq();
						findsearchCow();
					} else {
						mui.alert(bb.head.info);
					}
				},
				complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
					dismissDialog();
					if(status == 'timeout') { //超时,status还有success,error等值的情况
						ajaxTimeoutTest.abort();　　　　　
						mui.alert("网络请求超时...");　　　　
					}　　
				}
			}); 		
		}
		</script>
	</body>

</html>